package com.loadmore.common.util;

import android.content.Context;
import android.graphics.PixelFormat;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;

/**
 * Created by sunleilei on 2017/3/10
 */

public class UIUtil {

    public static void addWindow(Context context) {
        Context ct = context.getApplicationContext();
        WindowManager windowManager =Util.getWindowManager(context);
        FrameLayout root = new FrameLayout(ct);
        root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.setTitle("");
        params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        params.format = PixelFormat.TRANSLUCENT;
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height =WindowManager.LayoutParams.WRAP_CONTENT;
        params.x = 0;
        params.y = 0;
        params.gravity = Gravity.CENTER;
        windowManager.addView(root,params);

    }
}
